/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.railway.utils;

/**
 *
 * @author Kenny
 */
import java.io.File;
import javax.swing.filechooser.*;

public class ImageFilter extends FileFilter {

    //Accept all directories and all gif, jpg, tiff, or png files.
    @Override
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }

        String extension = ImageExtension.getExtension(f);
        if (extension != null) {
            if (extension.equals(ImageExtension.tiff)
                    || extension.equals(ImageExtension.tif)
                    || extension.equals(ImageExtension.gif)
                    || extension.equals(ImageExtension.jpeg)
                    || extension.equals(ImageExtension.jpg)
                    || extension.equals(ImageExtension.png)) {
                return true;
            } else {
                return false;
            }
        }

        return false;
    }

    //The description of this filter
    @Override
    public String getDescription() {
        return "Images only";
    }
}